/*
 * LTMFrequencies.c
 *
 *  Created on: Jun 26, 2013
 *      Author: koldar
 */

#include "main-tools.h"
#include "LTMFrequencies.h"

//TODO testing
PLTMFrequencies initLTMFrequencies(int* K,int* N){
	PLTMFrequencies result=(PLTMFrequencies)malloc(sizeof(LTMFrequencies));
	checkMalloc(result,"LTMFrequencies.c:initLTMFrequencies:1");
	result->K=K;
	result->vehicleMatrices=(PfMatrix*)malloc(*K*sizeof(PfMatrix));
	checkMalloc(result,"LTMFrequencies.c:initLTMFrequencies:2");
	int i;
	for (i=0;i<*K;i++){
		result->vehicleMatrices[i]=initFMatrix(N);
		checkMalloc(result->vehicleMatrices[i],"LTMFrequencies.c:initLTMFrequencies:3");
	}
	return result;
}
//TODO testing
void freeLTMFrequencies(PLTMFrequencies obj){
	int i;
	for (i=0;i<*obj->K;i++){
		freeFMatrix(obj->vehicleMatrices[i]);
	}
	free(obj);
}

void printLTMFrequencies(FILE* f,PLTMFrequencies obj){
	int i;
	for (i=0;i<*obj->K;i++){
		fprintf(f,"VEHICLE %d\n",i);
		printFMatrix(f,obj->vehicleMatrices[i]);
	}
}
